<?php
namespace app\admin\controller;

use app\common\controller\AdminBase;
use think\Db;
use app\common\model\Domain as DomainModel;

/**
 * 后台首页
 * Class Index
 * @package app\admin\controller
 */
class Index extends AdminBase
{
    protected $domain_model;

    protected function _initialize()
    {
        parent::_initialize();
        $this->domain_model = new DomainModel();
    }

    /**
     * 首页
     * @return mixed
     */
    public function index($page = 1)
    {
        if(is_mobile()){
            $domain_list = $this->domain_model->paginate(15,false,['page'=>$page]);
            $this->assign('domain_list',$domain_list);
            return $this->fetch('index');
        }else{
            $version = Db::query('SELECT VERSION() AS ver');
            $config  = [
                'url'             => $_SERVER['HTTP_HOST'],
                'document_root'   => $_SERVER['DOCUMENT_ROOT'],
                'server_os'       => PHP_OS,
                'server_port'     => $_SERVER['SERVER_PORT'],
                'server_soft'     => $_SERVER['SERVER_SOFTWARE'],
                'php_version'     => PHP_VERSION,
                'mysql_version'   => $version[0]['ver'],
                'max_upload_size' => ini_get('upload_max_filesize')
            ];

            return $this->fetch('index', ['config' => $config]);
        }
    }
}